package com.mycloud.product.client;

import com.mycloud.product.common.DecreaseStock;
import com.mycloud.product.common.ProductInfoOutput;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

/**
 * Created by PC on 2019/1/5.
 */
//@FeignClient(name = "product",fallback = ProductClient.ProductClientFallback.class)
@FeignClient(name = "product")
public interface ProductClient {

    @GetMapping("/msg")
    public String getMsg();

    @PostMapping("/product/listForOrder")
    List<ProductInfoOutput> listProductByIdList(List<String> productIdList);

    @PostMapping("/product/decreaseStock")
    public void decreaseStock(@RequestBody List<DecreaseStock> cartDTOList);

    @Component
    static class ProductClientFallback implements ProductClient{

        @Override
        public String getMsg() {
            return null;
        }

        @Override
        public List<ProductInfoOutput> listProductByIdList(List<String> productIdList) {
            return null;
        }

        @Override
        public void decreaseStock(List<DecreaseStock> cartDTOList) {

        }
    }
}
